#!/bin/sh

NAME=bora_v2
HOST_BORA_BIN_PATH=/root/billy/bora_bin
HOST_HTTP_PORT=18666
HOST_MQTT_PORT=8883
CONTAINER_BORA_BIN_PATH=/srv/bora_deploy/bora_bin
CONTAINER_WORKSPACE=$CONTAINER_BORA_BIN_PATH/bora/src/server
IMAGE_TAG=microembed/bora_v2:201808

if [ 1 -le $# ] && [ "create" = $1 ]; then
    docker build -t $IMAGE_TAG .
    docker run --name $NAME -v $HOST_BORA_BIN_PATH:$CONTAINER_BORA_BIN_PATH -w $CONTAINER_WORKSPACE $IMAGE_TAG ./bora_v2_init.sh | tee bora_v2_init.log
    docker commit $NAME $IMAGE_TAG
    docker rm $NAME
else
    docker run --name $NAME -d -p 127.0.0.1:$HOST_HTTP_PORT:80 -p $HOST_MQTT_PORT:1883 -v $HOST_BORA_BIN_PATH:$CONTAINER_BORA_BIN_PATH -w $CONTAINER_WORKSPACE  $IMAGE_TAG supervisord
fi



